/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 *  Name       : 装置分布汇总
 */


var fieldLabel = new Array('单位', '启用', '停用', '启用', '停用', '启用', '停用', '启用', '停用');
var fieldLabel1 = new Array('A类', 'B类', 'C类', 'D类');
var fieldName = new Array('orgName', 'AStartCount', 'AStopCount', 'BStartCount', 'BStopCount', 'CStartCount', 'CStopCount', 'DStartCount', 'DStopCount', 'rn');
var _pageSize = 100;

//alert(Ext.getCmp('dateFrom'));
///alert(yestoday);
var beginDate = lastMonth.format('Ymd');
var endDate = yestoday.format('Ymd');

var store = new Ext.data.JsonStore({
    url: basePath + "servlet/system/PointLoad",
    root: 'data',
    idProperty: 'id',
    totalProperty: 'count',
    fields: fieldName,
    autoLoad: true,
    baseParams: {cmd: cmd, dateFrom: beginDate, dateTo: endDate, start: 0, limit: _pageSize}
});

var colModel = new Ext.grid.ColumnModel({
    columns: [
        /*{
         header: '序号',
         width: 100,
         dataIndex: 'rn',
         align: 'left'
         },*/
        new Ext.grid.RowNumberer({
            header: '序号',
            align: 'center',
            width: 40
        }),
        {
            header: fieldLabel[0],
            width: 100,
            dataIndex: fieldName[0],
            align: 'center'
        },
        {
            header: fieldLabel[1],
            width: 100,
            dataIndex: fieldName[1],
            align: 'center'
        },
        {
            header: fieldLabel[2],
            width: 100,
            dataIndex: fieldName[2],
            align: 'center'
        },
        {
            header: fieldLabel[3],
            width: 100,
            dataIndex: fieldName[3],
            align: 'center'
        },
        {
            header: fieldLabel[4],
            width: 100,
            dataIndex: fieldName[4],
            align: 'center'
        },
        {
            header: fieldLabel[5],
            width: 100,
            dataIndex: fieldName[5],
            align: 'center'
        },
        {
            header: fieldLabel[6],
            width: 100,
            dataIndex: fieldName[6],
            align: 'center'
        },
        {
            header: fieldLabel[7],
            width: 100,
            dataIndex: fieldName[7],
            align: 'center'
        },
        {
            header: fieldLabel[8],
            width: 100,
            dataIndex: fieldName[8],
            align: 'center'
        },
    ],
    defaultSortable: true,
    rows: [
        [
            {
                width: 100,
                rowspan: 1
            },
            {
                width: 100,
                rowspan: 1
            },
            {
                width: 100,
                header: fieldLabel1[0],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[1],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[2],
                colspan: 2,
                align: 'center'
            },
            {
                width: 100,
                header: fieldLabel1[3],
                colspan: 2,
                align: 'center'
            }
        ]
    ]
});

var grid = new Ext.grid.GridPanel({
    title: _title,
    store: store,
    colModel: colModel,
    enableColumnMove: false,
    viewConfig: {
        forceFit: true
    },
    plugins: [new Ext.ux.plugins.GroupHeaderGrid()],
    loadMask: true,
    tbar: new Ext.Toolbar([
        reportCombo,
        rangeCombo,
        '-',
        {
            text: "日期范围：",
            xtype: 'label',
            style: {
                marginLeft: '20px'
            }
        }
        ,
        dateFromField,
        '-',
        {
            text: "至：",
            xtype: 'label',
            style: {
                marginLeft: '20px'
            }
        },
        dateToField,
        '-',
        {
            xtype: 'button',
            text: '搜索',
            iconCls: 'icon-search',
            width: 60,
            style: {
                marginLeft: '20px'
            },
            handler: function() {
                store.load({
                    params: {
                        start: 0,
                        limit: _pageSize
                    }
                });
            }
        },
    ]),
    bbar: new Ext.PagingToolbar({
        pageSize: _pageSize,
        store: store,
        displayInfo: true,
        displayMsg: '显示记录：{0} - {1}   总记录：{2}',
        emptyMsg: '目前没有信息'
    })
});
store.load({
    params: {
        start: 0,
        limit: _pageSize
    }
});



function buildWindow() {
    var applicationUI = new Ext.Viewport({
        layout: 'fit',
        items: [
            grid
        ]
    });
}
Ext.onReady(buildWindow); 